package model;

import java.util.ArrayList;
import java.util.TreeSet;








import javax.swing.table.AbstractTableModel;


import views.WerknemersPanel;
import datalayer.abstractFactory.DAOFactory;


public class TableModel extends AbstractTableModel{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	String[] ColumnNames = {"Voornaam", "Tussenvoegsel", "Achternaam", "Email", "Telefoonnummer", "Functie"};
	private TreeSet<Werknemer> wrkn = DAOFactory.getFactory().getDAOWerknemer().loadAll();
	private WerknemersPanel werkpanel;
	
	public TableModel(){


		//super();
		//System.out.println(DAOFactory.getFactory().getDAOWerknemer().loadAll());
	}

	@Override
	public int getColumnCount() {
		
		return 6;
	}
	
	@Override
	public boolean isCellEditable(int row, int column){  
        return false;  
    }	

	@Override
	public int getRowCount() {
		return wrkn.size();
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		ArrayList<Werknemer> temp = new ArrayList<>(wrkn);
		
		Werknemer w = temp.get(rowIndex);
            
            	 switch(columnIndex){
         		case 0:
         			return w.getVoornaam();
         		case 1:
         			return w.getTussenvoegsel();
         		case 2:
         			return w.getAchternaam();
         		case 3:
         			return w.getEmail();
         		case 4:
         			return w.getTelefoonnummer();
         		case 5:
         			return w.getFunctie();
         			default:
         				return null;
            
        }

	}

	@Override
	public String getColumnName(int column) {
		
		return ColumnNames[column];
	}	
}
